Plotly Package Review

Jonathan Yu, Jaden Stanford, Joseph Keogh

Package Overview

History of Plotly

Plotly is a company founded by Alex Johnson, Jack Parmer, Chris Parmer, and Matthew Sundquistin 2013. While working for the data science program of a California-based cleantech company, Alex, Jack, Chris, and Matthew found themselves facing the seemingly simple problem of having to find a way to meaningfully and easily share the data they’ve gathered. Even after collecting, analyzing, and sorting data, they felt that there were still important questions that had to be answered. These questions included:

  • How do we share what we’ve learned with others in a meaningful way?
  • How do we enable others to explore our data?
  • Can we give others access to the models to explore on their own?

To answer these questions they decided to create a tool to make scientific and data analysis simple. Plotly was actually originally a JavaScript graphing library which was eventually converted into an R package which allowed the creation of graphs using R data and syntax from ggplot2. Their focuses with plotly were to use the web as a data science platform, power discovery with open source, provide unlimited flexibility, remove language as a barrier, and enable shared goals across the organization. In 2013 and 2014, Jack, Chris, Matthew, and Alex officially founded “plotly” and opened their Montreal headquarters.

Background of Plotly

Plotly is a graphing library that makes interactive, publication-quality graphs. Oftentimes with data visualization, people run into issues with making graphs both interesting and informative. However, with plotly this can be done easily as plotly allows for the creation of a wide variety of visualizations ranging from basic bar-graphs to maps, 3d charts, and animated charts with a few lines of code. In addition to being easy to use, plotly is also an open-source package that can be found on numerous platforms including R, Python, .NET, JS, and Julia.

Version History

Current Version: 4.9.3 (last updated 1/10/2021)

Dependencies

R (≥ 3.2.0), ggplot2 (≥ 3.0.0)

Usage

plotly offers a wide variety of interactive options allowed on a web-based application which include:

##Examples of Usage plotly converts plots to an interactive, web-based version. It allows for zooming in or out of a graph, selection of data points

  • zooming in or out of a graph
  • selection of data points upon mouse hover
  • panning through a graph
  • downloading a graph as a PNG
  • box selecting or lasso selecting data points
  • option to compare nearby data points upon hover

visual formats supported by plotly include:

  • basic charts (scatter and line plots, bar charts, pie charts, bubble charts, and more)
  • statistical charts (2D Histograms, box plots, histograms, error bars, violin plots, and more)
  • scientific charts (log plots, contour plots, heatmaps, network graph, ternary contour plots, and more)
  • financial charts (time series, candlestick charts, OHLC charts, waterfall charts, funnel charts, and more)
  • maps (chloropleth maps, scatter plots on maps, mapbox density, lines on maps, mapbox layers, and more)
  • 3D Charts (3D scatter plots, 3d line plots, 3d surface plots, 3d mesh plots, 3d cone plots, and more)
  • subplots (multiple axes, map subplots and small multiples, inset plots, subplots, 3d subplots, and more)
  • animated plots

Similar Packages

leaflet

ggplot2

dygraphs

Examples of Usage

Bubble Chart

One of the most basic charts that you are able to create in plotly is the bubble chart. A bubble chart is a scatter plot whose markers have variable color and size. In this example we will be making a bubble plot from scratch using plotly and the built in mtcars dataset in R.

figure <- plot_ly(
  data = mtcars, #specified dataset, in this case we are using mtcars
  x = ~mpg, #variable that corresponds with x-axis 
  y = ~hp, #variable that corresponds with y-axis
  text = rownames(mtcars), #specifies text that shows up when you hover over a data point
  type = 'scatter', #specified graph type, in this case we are using the scatter plot
  mode = 'markers', 
  marker = list(size = ~cyl, opacity = 0.5, color = 'green')) #marker parameter specifies the size, opacity, and color of each of our bubbles.  

figure <- figure %>%
  layout(title = 'Gas Efficiency and Speed of Cars in mtcars dataset')
figure

Reflection